package com.hee.erp.modules.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hee.erp.common.R;
import com.hee.erp.modules.entity.SysLog;
import com.hee.erp.modules.service.ISysLogService;
import com.hee.erp.modules.service.ISysUserService;
import com.hee.erp.vo.FiltersOption;
import com.hee.erp.vo.LogListParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author weizehong
 * @since 2022-03-15
 */
@RestController
@RequestMapping("/modules/sysLog")
public class SysLogController {

    @Autowired
    ISysLogService sysLogService;

    @Autowired
    ISysUserService sysUserService;

    @PostMapping("/listByPage")
    @ApiOperation(value = "listByPage")
    public R<IPage<SysLog>> listByPage(@RequestBody LogListParams params){
        IPage<SysLog> page = sysLogService.listByPage(params);
        return R.success(page);
    }

    @ApiOperation(value = "getDetailById")
    @GetMapping("/getById")
    public R<SysLog> getById(String id){
        SysLog sysLog = this.sysLogService.getDetailById(id);
        return R.success(sysLog);
    }

    @PostMapping("/save")
    @ApiOperation(value = "save")
    public R<Boolean> save(@RequestBody SysLog sysLog){
        sysLogService.saveOrUpdate(sysLog);

        return R.success(true);
    }

    @ApiOperation("delById")
    @GetMapping("/delById")
    public R<Boolean> delById(String id){
        sysLogService.removeById(id);
        return R.success(true);
    }

    @GetMapping("/getFiltersOptions")
    @ApiOperation("getFiltersOptions")
    public R<List<FiltersOption>> getFiltersOptions(){
        List<FiltersOption> list = sysLogService.getFiltersOptions();
        return R.success(list);
    }

}

